package system.task.tasks;

import lombok.SneakyThrows;
import org.springframework.stereotype.Component;
import system.task.ExecutorContext;
import system.task.Task;
import system.task.TaskExecutor;
import system.task.TaskLogger;

@Component
public class WaitTask implements TaskExecutor {

    @SneakyThrows
    @Override
    public void run(ExecutorContext context) {
        Task task = context.getTask();
        TaskLogger logger = context.getLogger();

        logger.writeln("*** BEGIN: " + task.getName());

        logger.writeln("Wait 3600 sec.");
        synchronized (this) {
            this.wait(3600 * 1000);
        }

        logger.writeln("*** END: " + task.getName());
    }
}
